#ifndef ATS_GENERATOR_CATS
#define ATS_GENERATOR_CATS

#include <pthread.h>

ATSinline()
pthread_mutex_t *
generator_lock_make (void) {
  pthread_mutex_t *mutex = ats_malloc_gc(sizeof(pthread_mutex_t));
  if( pthread_mutex_init(mutex,0) ) {
    perror("Allocating Mutex Failed!\n");
    exit(1);
  }
  return mutex;
}

ATSinline()
ats_void_type
generator_lock_acquire(pthread_mutex_t *lock) {
  pthread_mutex_lock(lock);
}

ATSinline()
ats_void_type
generator_lock_release(pthread_mutex_t *lock) {
  pthread_mutex_unlock(lock);
}

ATSinline()
pthread_cond_t *
generator_cond_make(void) {
  pthread_cond_t *c = ats_malloc_gc(sizeof(pthread_cond_t));
  if( pthread_cond_init(c,0) ) {
    printf("Condition Failed to Allocate!\n");
  }
  return c;  
}

ATSinline()
ats_void_type
generator_cond_wait(pthread_cond_t *cond,pthread_mutex_t *wait) {
  pthread_cond_wait(cond,wait);
}

ATSinline()
void
generator_cond_signal(pthread_cond_t *cond) {
  pthread_cond_signal(cond); 
}

ATSinline()
void
generator_cond_broadcast(pthread_cond_t *cond) {
  pthread_cond_broadcast(cond);
}

#endif // end of [ATS_GENERATOR_CATS]
